		//开始定义一个用于展示弹出优惠券信息的窗体对象
		function couponWindow() {
		}
		couponWindow.prototype = new GControl();		
		couponWindow.prototype.initialize = function(map) {
		  var container = null;
		  container = document.getElementById("coupon_info");
		  if(!container)
		  {
			  container = document.createElement("div");
			  container.id = "coupon_info";
			  map.getContainer().appendChild(container);
		  }	  
		  GEvent.addListener(map, "moveend", function() {
					var container = document.getElementById("coupon_info");	
					container.innerHTML= "";
		  });
		  return container;
		}
		couponWindow.prototype.getDefaultPosition = function() {
		  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(300, 100));
		}		
		//定义结束

		/* 添加商户标注对象
		包括属性：
		1. 图标 icon, 绝对地址
		2. 坐标GLatLng对象
		3. 分店ID depart_id
		*/
		function createSupplier(map,latlng,supplier_title,icon,depart_id) {
			var gicon = new GIcon();
			gicon.image = icon;
			gicon.iconAnchor = new GPoint(16, 16);
			gicon.infoWindowAnchor = new GPoint(16, 0);
			var marker = new GMarker(latlng, {title:supplier_title,icon: gicon,draggable:false });	
			GEvent.addListener(marker, 'click', function(){
				map.addControl(new couponWindow());	
				//开始获取指定优惠券的信息
				var q = new Object();
				q.m = "Youhui";
				q.a = "get_coupon_info";
				q.id = depart_id;
				$.ajax({
					url: ROOT_PATH+"/index.php",
					data:q,
					cache:false,
					success:function(data)
					{		
						document.getElementById("coupon_info").innerHTML  = data;
					}
				});
			}); 
			map.addOverlay(marker);		
		}
	function close_coupon()
	{
		document.getElementById("coupon_info").innerHTML  = "";
	}
	

	function load_region(id,obj)
	{
		$(obj).parent().parent().find("a").removeClass("actt");
		$(obj).addClass("actt");
		var q = new Object();
		q.m = "Youhui";
		q.a = "set_region_cookie";
		q.region_id = id;
		$.ajax({
			url: ROOT_PATH+"/index.php",
			data:q,
			cache:false,
			success:function(data)
			{		
				initialize();
			}
		});
	}
	
	function load_cate(id,obj)
	{
		$(obj).parent().parent().find("a").removeClass("actt");
		$(obj).addClass("actt");
		var q = new Object();
		q.m = "Youhui";
		q.a = "set_cate_cookie";
		q.cate_id = id;
		$.ajax({
			url: ROOT_PATH+"/index.php",
			data:q,
			cache:false,
			success:function(data)
			{		
				initialize();
			}
		});
	}
	
    function initialize() {
      if (GBrowserIsCompatible()) {
    	  
			var map = new GMap2(document.getElementById("map_canvas"));
			
			  var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));

			  map.addControl(new GLargeMapControl(),topRight);


	         
			//开始获取商圈信息
			var query = new Object();
			query.m = "Youhui";
			query.a = "get_current_region";
			$.ajax({
				url: ROOT_PATH+"/index.php",
				data:query,
				cache:false,
				dataType:"json",
				success:function(data)
				{		
					map.setCenter(new GLatLng(data.ypoint, data.xpoint), parseInt(data.zoom));
					//开始获取商圈下的所有商户					
					var q = new Object();
					q.m = "Youhui";
					q.a = "get_supplier_list";
					$.ajax({
						url: ROOT_PATH+"/index.php",
						data:q,
						cache:false,
						dataType:"json",
						success:function(data)
						{		
							for(var i=0;i<data.length;i++)
							{
								createSupplier(map,new GLatLng(data[i].ypoint, data[i].xpoint),data[i].depart_name,data[i].icon,data[i].id);
							}
						}
					});
					//结束					
				}
			});

			
      }
    }
    
    
    
    $(document).ready(function(){
    	initialize();
    });
    
    function close_cate()
    {
    	if(document.getElementById("catalogMain").style.display!="none")
    	$("#catalogMain").slideUp("fast",function(){
    		document.getElementById("tog").className = "togopen";
    	});
    	else
    	$("#catalogMain").slideDown("fast",function(){
    		document.getElementById("tog").className = "tog";
    	});
    }
    function open_cate()
    {
    	if(document.getElementById("catalogMain").style.display!="none")
        	$("#catalogMain").slideUp("fast",function(){
        		document.getElementById("tog").className = "togopen";
        	});
        	else
        	$("#catalogMain").slideDown("fast",function(){
        		document.getElementById("tog").className = "tog";
        	});
    }